package iPersistence.sqlSession;

import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.List;

/**
 * @author Feuler
 * @since 2020/11/6
 **/

public interface SqlSession {
    /**
     * 查询多条记录
     *
     * @param statementId sql唯一id
     * @param params      可选参数
     * @param <E>         返回对象类型
     * @return 结果对象list
     * @throws SQLException
     * @throws IllegalAccessException
     * @throws IntrospectionException
     * @throws InstantiationException
     * @throws NoSuchFieldException
     * @throws NoSuchMethodException
     * @throws InvocationTargetException
     * @throws ClassNotFoundException
     */
    <E> List<E> selectList(String statementId, Object... params) throws SQLException, IllegalAccessException, IntrospectionException, InstantiationException, NoSuchFieldException, NoSuchMethodException, InvocationTargetException, ClassNotFoundException;

    /**
     * 查询单条记录
     *
     * @param statementId sql唯一id
     * @param params      可选参数
     * @param <T>         返回对象类型
     * @return 结果对象
     * @throws SQLException
     * @throws IllegalAccessException
     * @throws InvocationTargetException
     * @throws IntrospectionException
     * @throws InstantiationException
     * @throws ClassNotFoundException
     * @throws NoSuchMethodException
     * @throws NoSuchFieldException
     */
    <T> T selectOne(String statementId, Object... params) throws SQLException, IllegalAccessException, InvocationTargetException, IntrospectionException, InstantiationException, ClassNotFoundException, NoSuchMethodException, NoSuchFieldException;

    /**
     * 更新记录
     */
    void update();

    /**
     * 删除记录
     */
    void delete();


    /**
     * 为DAO接口生成代理实现类
     *
     * @param mapperClass
     * @param 被代理的类
     * @return 代理类
     */
    <T> T getMapper(Class<?> mapperClass);
}
